﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ArticleList.aspx.cs" Inherits="Myproject.BSM.PcWeb.PcChannel.Article.ArticleList" %>

<div class="bjui-pageHeader">
    <form id="pc_channel_article_form" data-toggle="ajaxsearch" action="/bsm/pcweb/PcChannel/Article/ArticleList.aspx" method="post">
    <div class="bjui-searchBar">
        <ul class="breadcrumb">
            <li><a><i class="fa fa-university"></i>后台管理中心</a></li>
            <li><a><i class="fa fa-desktop"></i>电脑端管理</a></li>
            <li class="active"><a><i class="fa fa-list"></i>频道管理</a></li>
        </ul>
    </div>
    <div class="bjui-searchBar">
        <a class="btn btn-orange" href="javascript:;" data-toggle="reloadsearch" data-clear-query="true" data-icon="undo">刷新</a>
        <a class="btn btn-green" href="/bsm/pcweb/PcChannel/Article/ArticleEdit.aspx?pid=0" data-toggle="dialog" data-width="600" data-height="200" data-id="addchannel" data-icon="plus">添加主频道</a>
    </div>
    </form>
</div>
<div class="bjui-pageContent">
    <table class="table table-bordered table-hover table-striped table-top" data-selected-multi="true" style="text-align: center;">
        <caption style="text-align: left;">
            <div class="alert alert-warning form-inline"><i class="fa fa-warning"></i> <strong>注意：</strong>图文频道只支持3层结构</div>
        </caption>
        <thead>
            <tr>
                <th style="text-align: center;">ID</th>
                <th style="text-align: center;">标题</th>
                <th style="text-align: center;">状态</th>
                <th style="text-align: center;">操作
                </th>
            </tr>
        </thead>
        <tbody>

            <%if (MessageTable != null && MessageTable.Rows.Count > 0)
              {
                  System.Data.DataRow[] rows1 = MessageTable.Select(" ParentId='0'");
                  foreach (System.Data.DataRow row in rows1)
                  {%>
            <tr>
                <td style="text-align: left;"><a href="#"><%= row["WebArticleId"] %></a></td>
                <td style="text-align: left;"><a href="#"><%= row["ChanneTitle"] %></a></td>
                <td>
                    <% if (bool.Parse(row["show"].ToString()))
                       { %>
                    <button onclick="javascript:pc_channel_article_js_show('<%= row["WebArticleId"] %>',false)" type="button" class="btn btn-green" data-icon="eye">已显示</button>
                    <%}
                       else
                       {
                    %>
                    <button onclick="javascript:pc_channel_article_js_show('<%= row["WebArticleId"] %>',true)" type="button" class="btn btn-red" data-icon="eye-slash">已隐藏</button>
                    <%
                       } %>
                </td>
                <td>
                    <a class="btn btn-red" href="javascript:pc_channel_article_js_delete('<%= row["WebArticleId"] %>')">删除</a>
                    <a class="btn btn-green" href="/bsm/pcweb/PcChannel/Article/ArticleEdit.aspx?id=<%= row["WebArticleId"] %>" data-toggle="dialog" data-width="600" data-height="200" data-id="pc_base_FriendEdit" data-title="编辑">编辑</a>
                    <a class="btn btn-green" href="/bsm/pcweb/PcChannel/Article/ArticleEdit.aspx?pid=<%= row["WebArticleId"] %>" data-toggle="dialog" data-width="600" data-height="200" data-id="pc_base_FriendEdit" data-title="添加子频道">添加子频道</a>
                    <% if (bool.Parse(row["isend"].ToString()))
                    { %>
                        <a class="btn btn-green" href="/bsm/pcweb/PcChannel/Article/NewsList.aspx?cid=<%= row["WebArticleId"] %>" data-toggle="navtab" data-id="pc_channel_newslist" data-title="图文列表">图文列表</a>
                        <a class="btn btn-green" href="/bsm/pcweb/PcChannel/Article/NewsEdit.aspx?cid=<%= row["WebArticleId"] %>" data-toggle="navtab" data-id="pc_channel_newsEdit" data-title="新增图文">新增图文</a>
                    <%}
                    %>
                </td>
            </tr>

            <%
                      System.Data.DataRow[] rows2 = MessageTable.Select(" ParentId='" + row["WebArticleId"] + "'");
                      if (rows2.Count() > 0)
                      {
                          foreach (System.Data.DataRow row2 in rows2)
                          {
            %>
            <tr>
                <td style="padding-left: 50px; text-align: left;">|__<a href="#"><%= row2["ChanneTitle"]%></a></td>
                <td style="padding-left: 50px; text-align: left;">|__<a href="#"><%= row2["EChanneTitle"]%></a></td>
                <% if (bool.Parse(row2["isurl"].ToString()))
                    { %>
                    <td><span class="label label-success"><%= row2["url"] %></span></td>
                    <td><span class="label label-success"><%= row2["url"] %></span></td>
                    <%}
                       else
                       {
                    %>
                    <td><span class="label label-success">生成</span></td>
                    <td><span class="label label-success">生成</span></td>
                    <%
                       } %>
                <td>
                    <% if (bool.Parse(row2["show"].ToString()))
                       { %>
                    <button onclick="javascript:pc_channel_article_js_show('<%= row2["WebArticleId"] %>',false)" type="button" class="btn btn-green" data-icon="eye">已显示</button>
                    <%}
                       else
                       {
                    %>
                    <button onclick="javascript:pc_channel_article_js_show('<%= row2["WebArticleId"] %>',true)" type="button" class="btn btn-red" data-icon="eye-slash">已隐藏</button>
                    <%
                       } %>
                </td>
                <td>
                    <% if (bool.Parse(row2["EShow"].ToString()))
                       { %>
                    <button onclick="javascript:pc_channel_article_js_show2('<%= row2["WebArticleId"] %>',false)" type="button" class="btn btn-green" data-icon="eye">已显示</button>
                    <%}
                       else
                       {
                    %>
                    <button onclick="javascript:pc_channel_article_js_show2('<%= row2["WebArticleId"] %>',true)" type="button" class="btn btn-red" data-icon="eye-slash">已隐藏</button>
                    <%
                       } %>
                </td>
                <td>
                    <a class="btn btn-red" href="javascript:pc_channel_article_js_delete('<%= row2["WebArticleId"] %>')">删除</a>
                    <a class="btn btn-green" href="/bsm/pcweb/PcChannel/Article/ArticleEdit.aspx?id=<%= row2["WebArticleId"] %>" data-toggle="dialog" data-width="600" data-height="200" data-id="pc_base_FriendEdit" data-title="编辑">编辑</a>
                    <a class="btn btn-green" href="/bsm/pcweb/PcChannel/Article/ArticleEdit.aspx?pid=<%= row2["WebArticleId"] %>" data-toggle="dialog" data-width="600" data-height="200" data-id="pc_base_FriendEdit" data-title="添加子频道">添加子频道</a>
                    <% if (bool.Parse(row2["isend"].ToString()))
                    { %>
                        <a class="btn btn-green" href="/bsm/pcweb/PcChannel/Article/NewsList.aspx?cid=<%= row2["WebArticleId"] %>" data-toggle="navtab" data-id="pc_channel_newslist" data-title="图文列表">图文列表</a>
                        <a class="btn btn-green" href="/bsm/pcweb/PcChannel/Article/NewsEdit.aspx?cid=<%= row2["WebArticleId"] %>" data-toggle="navtab" data-id="pc_channel_newsEdit" data-title="新增图文">新增图文</a>
                    <%}
                    %>
                </td>
            </tr>
            <%
                              System.Data.DataRow[] rows3 = MessageTable.Select(" ParentId='" + row2["WebArticleId"] + "'");
                              if (rows3.Count() > 0)
                              {
                                  foreach (System.Data.DataRow row3 in rows3)
                                  {
            %>
            <tr>
                <td style="padding-left: 100px; text-align: left;">|__<a href="#"><%= row3["ChanneTitle"]%></a></td>
                <td style="padding-left: 100px; text-align: left;">|__<a href="#"><%= row3["EChanneTitle"]%></a></td>
                <% if (bool.Parse(row3["isurl"].ToString()))
                    { %>
                    <td><span class="label label-success"><%= row3["url"] %></span></td>
                    <td><span class="label label-success"><%= row3["url"] %></span></td>
                    <%}
                       else
                       {
                    %>
                    <td><span class="label label-success">生成</span></td>
                    <td><span class="label label-success">生成</span></td>
                    <%
                       } %>
                <td>
                    <% if (bool.Parse(row3["show"].ToString()))
                       { %>
                    <button onclick="javascript:pc_channel_article_js_show('<%= row3["WebArticleId"] %>',false)" type="button" class="btn btn-green" data-icon="eye">已显示</button>
                    <%}
                       else
                       {
                    %>
                    <button onclick="javascript:pc_channel_article_js_show('<%= row3["WebArticleId"] %>',true)" type="button" class="btn btn-red" data-icon="eye-slash">已隐藏</button>
                    <%
                       } %>
                </td>
                <td>
                    <% if (bool.Parse(row3["EShow"].ToString()))
                       { %>
                    <button onclick="javascript:pc_channel_article_js_show2('<%= row3["WebArticleId"] %>',false)" type="button" class="btn btn-green" data-icon="eye">已显示</button>
                    <%}
                       else
                       {
                    %>
                    <button onclick="javascript:pc_channel_article_js_show2('<%= row3["WebArticleId"] %>',true)" type="button" class="btn btn-red" data-icon="eye-slash">已隐藏</button>
                    <%
                       } %>
                </td>
                <td>
                    <a class="btn btn-red" href="javascript:pc_channel_article_js_delete('<%= row3["WebArticleId"] %>')">删除</a>
                    <a class="btn btn-green" href="/bsm/pcweb/PcChannel/Article/ArticleEdit.aspx?id=<%= row3["WebArticleId"] %>" data-toggle="dialog" data-width="600" data-height="200" data-id="pc_base_FriendEdit" data-title="编辑">编辑</a>
                    <% if (bool.Parse(row3["isend"].ToString()))
                    { %>
                        <a class="btn btn-green" href="/bsm/pcweb/PcChannel/Article/NewsList.aspx?cid=<%= row3["WebArticleId"] %>" data-toggle="navtab" data-id="pc_channel_newslist" data-title="图文列表">图文列表</a>
                        <a class="btn btn-green" href="/bsm/pcweb/PcChannel/Article/NewsEdit.aspx?cid=<%= row3["WebArticleId"] %>" data-toggle="navtab" data-id="pc_channel_newsEdit" data-title="新增图文">新增图文</a>
                    <%}
                    %>
                </td>
            </tr>
            <%
                                  }
                              }
                          }
                      }
                  }
              } %>
           
        </tbody>
    </table>
</div>
<div class="bjui-pageFooter">
</div>
<script>
    function pc_channel_article_js_delete(id) {
        $(this).alertmsg('confirm', '确定要删除该频道吗?', {
            okCall: function () {
                $.ajax({
                    type: "post",
                    url: "/bsm/ashx/PcChannel/ArticleDelete.ashx?id=" + id,
                    dataType: "json",
                    beforeSend: function (XMLHttpRequest) {

                    },
                    success: function (data) {
                        if (data.IsError) {
                            $(this).alertmsg('correct', data.Message);
                            $(this).navtab('refresh', 'pc_channel_ArticleList');
                        }
                        else {
                            $(this).alertmsg('error', data.Message);
                        }
                    },
                    error: function () {
                        $(this).alertmsg('error', '删除失败，请稍后再试！');
                    }
                });
            }
        });
    }

    function pc_channel_article_js_show(id, show) {

        $.ajax({
            type: "post",
            url: "/bsm/ashx/PcChannel/ArticleShow.ashx?id=" + id + "&show=" + show,
            dataType: "json",
            beforeSend: function (XMLHttpRequest) {

            },
            success: function (data) {
                if (data.IsError) {
                    //$(this).alertmsg('correct', data.Message);
                    $(this).navtab('refresh', 'pc_channel_ArticleList');
                }
                else {
                    $(this).alertmsg('error', data.Message);
                }
            },
            error: function () {
                $(this).alertmsg('error', '操作失败，请稍后再试！');
            }
        });
    }
    function pc_channel_article_js_show2(id, show) {

        $.ajax({
            type: "post",
            url: "/bsm/ashx/PcChannel/ArticleShow2.ashx?id=" + id + "&show=" + show,
            dataType: "json",
            beforeSend: function (XMLHttpRequest) {

            },
            success: function (data) {
                if (data.IsError) {
                    //$(this).alertmsg('correct', data.Message);
                    $(this).navtab('refresh', 'pc_channel_ArticleList');
                }
                else {
                    $(this).alertmsg('error', data.Message);
                }
            },
            error: function () {
                $(this).alertmsg('error', '操作失败，请稍后再试！');
            }
        });
    }

</script>
